﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using DomainDriver.DomainModeling.DomainObjects;

namespace AutomotivePricingModel.ValueObjects.YearlyFinancialAssessments
{
    public partial class YearValueObservation : DomainObjectBase<YearValueObservation>
    {
        private int m_Year;
        private double m_Value;
        private Guid m_ParentYearlyFinancialAssessmentId;

        public YearValueObservation()
            : this(0, 0, Guid.Empty)
        { }

        public YearValueObservation(int year, double value, Guid parentYearlyFinancialAssessmentId)
        {
            m_ParentYearlyFinancialAssessmentId = parentYearlyFinancialAssessmentId;
            m_Year = year;
            m_Value = value;
        }

        //[Required]
        //[Association("Assc_YearValueObservation_YearlyFinancialAssessment", "EF_ParentYearlyFinancialAssessmentId", "EF_YearlyFinancialAssessmentId")]
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Column(Order = 0)]
        public Guid ParentYearlyFinancialAssessmentId
        {
            get { return m_ParentYearlyFinancialAssessmentId; }
            set { m_ParentYearlyFinancialAssessmentId = value; }
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Column(Order = 1)]
        public int Year
        {
            get { return m_Year; }
            set { m_Year = value; }
        }

        [Required]
        [Column(Order = 2)]
        public double Value
        {
            get { return m_Value; }
            set { m_Value = value; }
        }

        #region DomainObject Methods

        public override YearValueObservation Copy()
        {
            YearValueObservation copy = new YearValueObservation();
            CopyTo(copy);
            return copy;
        }

        public override void CopyTo(YearValueObservation otherObject)
        {
            if (otherObject.m_ParentYearlyFinancialAssessmentId != m_ParentYearlyFinancialAssessmentId)
            { otherObject.m_ParentYearlyFinancialAssessmentId = m_ParentYearlyFinancialAssessmentId; }
            if (otherObject.m_Year != m_Year)
            { otherObject.m_Year = m_Year; }
            if (otherObject.m_Value != m_Value)
            { otherObject.m_Value = m_Value; }
        }

        public override bool Equals(YearValueObservation otherObject)
        {
            if (otherObject.m_ParentYearlyFinancialAssessmentId != m_ParentYearlyFinancialAssessmentId)
            { return false; }
            if (otherObject.m_Year != m_Year)
            { return false; }
            if (otherObject.m_Value != m_Value)
            { return false; }
            return true;
        }

        #endregion
    }
}